<template>
  <div class="flex justify-between items-center pb-3">
    <div class="flex justify-end">
      <el-button type="primary" plain size="small" @click="onAdd()">新增评分点</el-button>
      <el-button
        v-if="showCollapse"
        :type="collapseFlag ? 'primary' : 'default'"
        plain
        size="small"
        @click="handleCollapse"
      >
        {{ collapseFlag ? '全部关闭' : '全部展开' }}
      </el-button>
      <UploadBtn @upload-success="uploadSuccess" />
      <el-button type="success" size="small" @click="downloadBtn">导入模板下载</el-button>
    </div>
  </div>
</template>
<script setup lang="ts">
import UploadBtn from './UploadBtn.vue'
import { downloadTemplate } from '@/hooks/use-common'
const props = defineProps({
  showCollapse: {
    type: Boolean,
    default: false
  },
  collapseFlag: {
    type: Boolean,
    default: false
  }
})
const fileUrl = `${import.meta.env.VITE_APP_FILE_URL}/评审项导入模板.xlsx`
const downloadBtn = async () => {
  downloadTemplate('评审项导入模板.xlsx', fileUrl)
}
const emit = defineEmits(['onAdd', 'uploadSuccess', 'handleCollapse'])
const onAdd = () => {
  emit('onAdd')
}
const uploadSuccess = (res: any) => {
  emit('uploadSuccess', res)
}
const handleCollapse = () => {
  emit('handleCollapse')
}
</script>
